package core.field;

import core.Player;

public abstract class  Ownable extends Field {
	protected int price;
	
	@Override
	public Player getOwner(){
		return owner;
	}

	@Override
	public abstract void landOnField(Player player);
	
	public abstract int getRent();
	public int getPrice(){
		return this.price;
	}
	public void setPrice(int price){
		this.price = price;
	}
	
	public void buyField(Player p){
		if(owner==null){
			owner = p;
			p.getKonto().withdrawPoints(getPrice());
			p.addFieldToPlayer(this);
		}
			
	}
	
	
	public String toString(){
		String temp;
		if(owner == null)
			temp = String.valueOf(price);
		else
			temp = owner.getName();
		return temp;
	}
	

}
